Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: multichain support #38

Merged
merged 6 commits into from
Nov 29, 2024
Merged

feat: multichain support #38

merged 6 commits into from
Nov 29, 2024

Conversation

0xnigir1
Copy link
Collaborator

@0xnigir1 0xnigir1 commented Nov 27, 2024

🤖 Linear

Closes GIT-177 GIT-178 GIT-179

Description

  • index remaining chains on Indexer app
  • enable multichain support on Processing app
  • fix InMemoryEventsRegistry to save events per chain
  • move out from Singleton pattern for logger as we want to log which Chain Orchestrator's makes a log

Checklist before requesting a review

  • I have conducted a self-review of my code.
  • I have conducted a QA.
  • If it is a core feature, I have included comprehensive tests.

Copy link

linear bot commented Nov 27, 2024

Copy link
Collaborator

@0xkenj1 0xkenj1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one ser ! 🫡

Comment on lines +76 to +79
for (const orchestrator of this.orchestrators.values()) {
this.logger.info(`Starting orchestrator for chain ${orchestrator.chainId}...`);
orchestratorProcesses.push(orchestrator.run(abortController.signal));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (const orchestrator of this.orchestrators.values()) {
this.logger.info(`Starting orchestrator for chain ${orchestrator.chainId}...`);
orchestratorProcesses.push(orchestrator.run(abortController.signal));
}
const orchestratorProcesses = this.orchestrators.values().map(orchestrator=>orchestrator.run);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but we're not passing the AbortController here, the AbortController is so we can gracefully exit the app so it finishes the current event being processed and then exits the app

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's missing in my suggestion but you can xd

orchestratorProcesses.push(orchestrator.run(abortController.signal));
}

await Promise.allSettled(orchestratorProcesses);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets keep in mind that we should make all the orchestrators to be infinite running processes, never throw errors, and have automatic recovery. This is to avoid affecting the others. In case we have inifinite running processes and never throw errors, then Promise.allSettled or Promise.all both should be the same since none of the processes resolve. Apart from automatic recovery we should notify once there is a critical error that kills the specific orchestrator.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree that all and allSettled are the same here. You're suggesting to use all so we can catch early a possible Fatal error that killed the Orchestrator?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be the same using allSettled or all because all are infinite processes and each of them should avoid bubbling up errors

Copy link
Collaborator

@jahabeebs jahabeebs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some optional questions/comment👍

// Initialize EVM provider
const evmProvider = new EvmProvider(env.RPC_URLS, optimism, this.logger);
for (const chain of chains) {
const chainLogger = new Logger({ chainId: chain.id as ChainId });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to initialize a logger for each chain?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we come up to this change because we want to distinguish logs for each chain (adding some identifier string as part of general formatting)

@@ -55,13 +55,22 @@ export class SharedDependenciesService {
kyselyDatabase,
env.DATABASE_SCHEMA,
);
const pricingProvider = PricingProviderFactory.create(env, { logger });
const pricingProvider = PricingProviderFactory.create(env, {
logger: new Logger({ className: "PricingProvider" }),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my last comment, do you think it's better not to use DI for the logger?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm could be 🤔 but at the same time i like DI... wdyt @0xkenj1

import { Orchestrator } from "@grants-stack-indexer/data-flow";

import type { Environment } from "../../src/config/env.js";
import { ProcessingService } from "../../src/services/processing.service.js";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import from index no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, however i don't think is much of a problem in test files

@0xnigir1 0xnigir1 requested a review from 0xkenj1 November 29, 2024 13:33
@0xnigir1 0xnigir1 merged commit 8d06292 into dev Nov 29, 2024
6 checks passed
@0xnigir1 0xnigir1 deleted the feat/multichain-support branch November 29, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants